﻿using System;
using System.Collections.Generic;
using System.Text;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.IBatisRepository;
using OneMG.Phoenix.Respository;
using System.Data;
using OneMG.Phoenix.Entity;

namespace OneMG.Phoenix.Service
{
    public class AdminUserRightService : IAdminUserRightService
    {
		 IAdminUserRight adminUserRight = new AdminUserRightRepository();
		 
        public System.Int32 AddAdminUserRight(AdminUserRightModel model)
        {
			EAdminUserRight entity = ConvertModelToEntity(model);
			
            return adminUserRight.AddAdminUserRight(entity);
        }

		public void UpdateByAdminUserRightID (AdminUserRightModel model)
		{
			EAdminUserRight entity = ConvertModelToEntity(model);

            adminUserRight.UpdateByAdminUserRightID(entity);

		}

		public void DeleteByAdminUserRightID (System.Int32 adminUserRightID)
		{
		
            adminUserRight.DeleteByAdminUserRightID(adminUserRightID);

		}
		 
        public AdminUserRightModel GetByAdminUserRightID (System.Int32 adminUserRightID)
        {
        
			EAdminUserRight entity = adminUserRight.GetByAdminUserRightID(adminUserRightID);
			
            AdminUserRightModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminUserRightModel ConvertEntityToModel(EAdminUserRight entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminUserRightModel model = new AdminUserRightModel();
                        model.AdminUserRightID = entity.AdminUserRightID;
                        model.UserID = entity.UserID;
                        model.RightID = entity.RightID;
                        return model;
		}
		
		public EAdminUserRight ConvertModelToEntity(AdminUserRightModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminUserRight entity = new EAdminUserRight();
                        entity.AdminUserRightID = model.AdminUserRightID;
                        entity.UserID = model.UserID;
                        entity.RightID = model.RightID;
                        return entity;
		}
    }
}